package edu.citadel.presentation.context;

import net.sourceforge.stripes.action.ActionBeanContext;

/**
] * User: jordan
 * Date: 2/24/13
 * Time: 11:43 AM
 */
public class Context extends ActionBeanContext {


    public static String getJspPath(String jsp) {
        return "/WEB-INF/jsp/" + jsp;
    }

    public static String getCssPath(String jsp) {
        return "/WEB-INF/css/" + jsp;
    }

    public static String getJsPath(String jsp) {
        return "/WEB-INF/js/" + jsp;
    }

    public boolean isGet() {
        return getRequest().getMethod().equals("GET");
    }

    public boolean isPost() {
        return getRequest().getMethod().equals("POST");
    }

    public boolean isAjaxRequest() {
        /*
        return "XMLHttpRequest".equals(getRequest().getHeader("X-Requested-With"));
        */
        return ("XMLHttpRequest".equals(getRequest().getHeader("X-Requested-With")) ||
                ("XMLHttpRequest".equals(getRequest().getParameter("X-Requested-With")))); // iframe ajax fake
    }

}
